load("//rs/tests:common.bzl", "GRAFANA_RUNTIME_DEPS", "MAINNET_ENV", "XNET_TEST_CANISTER_RUNTIME_DEPS")
load("//rs/tests:system_tests.bzl", "system_test", "system_test_nns")

package(default_visibility = ["//rs:system-tests-pkg"])

system_test_nns(
    name = "xnet_slo_120_subnets_staging_test",
    enable_head_nns_variant = False,  # Let's not run this expensive test against the HEAD NNS canisters to save resources.
    env = {
        "XNET_TEST_CANISTER_WASM_PATH": "$(rootpath //rs/rust_canisters/xnet_test:xnet-test-canister)",
    },
    tags = [
        "system_test_large",
    ],
    test_timeout = "eternal",
    runtime_deps = XNET_TEST_CANISTER_RUNTIME_DEPS + GRAFANA_RUNTIME_DEPS,
    deps = [
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/tests/message_routing/xnet/slo_test_lib:xnet_slo_test_lib",
        "@crate_index//:anyhow",
    ],
)

system_test_nns(
    name = "xnet_slo_3_subnets_hotfix_test",
    enable_head_nns_variant = False,  # only run this test with the mainnet NNS canisters.
    env = {
        "XNET_TEST_CANISTER_WASM_PATH": "$(rootpath //rs/rust_canisters/xnet_test:xnet-test-canister)",
    },
    tags = [
        "system_test_large",
    ],
    runtime_deps = XNET_TEST_CANISTER_RUNTIME_DEPS + GRAFANA_RUNTIME_DEPS,
    deps = [
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/tests/message_routing/xnet/slo_test_lib:xnet_slo_test_lib",
        "@crate_index//:anyhow",
    ],
)

system_test_nns(
    name = "xnet_slo_3_subnets_test",
    enable_head_nns_variant = False,  # only run this test with the mainnet NNS canisters.
    env = {
        "XNET_TEST_CANISTER_WASM_PATH": "$(rootpath //rs/rust_canisters/xnet_test:xnet-test-canister)",
    },
    tags = [
        "system_test_large",
    ],
    runtime_deps = XNET_TEST_CANISTER_RUNTIME_DEPS + GRAFANA_RUNTIME_DEPS,
    deps = [
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/tests/message_routing/xnet/slo_test_lib:xnet_slo_test_lib",
        "@crate_index//:anyhow",
    ],
)

system_test_nns(
    name = "xnet_slo_29_subnets_test",
    enable_head_nns_variant = False,  # only run this test with the mainnet NNS canisters.
    env = {
        "XNET_TEST_CANISTER_WASM_PATH": "$(rootpath //rs/rust_canisters/xnet_test:xnet-test-canister)",
    },
    tags = [
        "system_test_large",
    ],
    test_timeout = "eternal",
    runtime_deps = XNET_TEST_CANISTER_RUNTIME_DEPS + GRAFANA_RUNTIME_DEPS,
    deps = [
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/tests/message_routing/xnet/slo_test_lib:xnet_slo_test_lib",
        "@crate_index//:anyhow",
    ],
)

system_test(
    name = "xnet_malicious_slices",
    env = {
        "XNET_TEST_CANISTER_WASM_PATH": "$(rootpath //rs/rust_canisters/xnet_test:xnet-test-canister)",
    },
    uses_guestos_img = False,
    uses_guestos_malicious_img = True,
    runtime_deps = GRAFANA_RUNTIME_DEPS + XNET_TEST_CANISTER_RUNTIME_DEPS,
    deps = [
        "//rs/registry/subnet_type",
        "//rs/rust_canisters/canister_test",
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/tests/message_routing/common:systest_message_routing_common",
        "//rs/types/types",
        "@crate_index//:anyhow",
        "@crate_index//:slog",
        "@crate_index//:tokio",
    ],
)

system_test_nns(
    name = "xnet_compatibility",
    enable_head_nns_variant = False,  # only run this test with the mainnet NNS canisters.
    env = {
        "XNET_TEST_CANISTER_WASM_PATH": "$(rootpath //rs/rust_canisters/xnet_test:xnet-test-canister)",
    } | MAINNET_ENV,
    tags = [
        "long_test",
    ],
    uses_guestos_img = False,
    uses_guestos_mainnet_nns_img = True,
    uses_guestos_update = True,
    runtime_deps =
        XNET_TEST_CANISTER_RUNTIME_DEPS +
        GRAFANA_RUNTIME_DEPS,
    deps = [
        "//rs/registry/subnet_type",
        "//rs/tests/consensus/utils",
        "//rs/tests/driver:ic-system-test-driver",
        "//rs/tests/message_routing/xnet/slo_test_lib:xnet_slo_test_lib",
        "//rs/types/types",
        "@crate_index//:anyhow",
        "@crate_index//:slog",
        "@crate_index//:tokio",
    ],
)
